<html>

<head>
    <title>createTextNode example</title>

    <script type="text/javascript">
        function addTextNode() {
            var newtext = document.createTextNode("动态添加一些文本");
            var para = document.getElementById("p1");
            para.appendChild(newtext);
        }
    </script>
</head>

<body>
    <div style="border: 1px solid red">
        <p id="p1">一段话的第一行.<br /></p>
    </div><br />

    <button onclick="addTextNode();">添加一个文本节点.</button>

</body>
<script>
    let p = document.querySelector('p');
    p.addEventListener('click', function() {
        alert('点击');
    })
</script>
</html>